package com.m2bshop.shop.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.m2bshop.shop.pojo.BMCgoods;
import com.m2bshop.shop.pojo.Favorites;
import com.m2bshop.shop.pojo.JM;
import com.m2bshop.shop.pojo.JMFgoods;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author asus
 * @create 2022/6/12 15:31
 */
@Mapper
@Repository
public interface JMFgoodsDao extends BaseMapper<JMFgoods> {
    //查询所有商品信息
    @Select("select * from JMFgoods")
    public List<JMFgoods> GetGoodsList();

   /* @Select("select * from JMFgoods where id = #{id}")*/
   /* public JMFgoods GetGoodsById(@Param(value = "id") int id);*/

    //添加到心愿单
    @Insert("Insert into favorite (name,model,price,dlperiod,weight,userid,gid) values (#{favorites.name},#{favorites.model},#{favorites.price},#{favorites.dlperiod},#{favorites.weight},#{favorites.userid},#{favorites.gid}) " )
    public int AddGoods(@Param("favorites") Favorites favorites);
    /*public int updateGoods(JMFgoods goods);
    public int deleteGoods(int id);*/


    @Select("select * from JMFgoods where id=#{id}")
    public JMFgoods getGoodsInfo(@Param("id") Integer id);

    @Insert("Insert into JM (name,model,price,dlperiod,weight,userid,gid) values (#{jm.name},#{jm.model},#{jm.price},#{jm.dlperiod},#{jm.weight},#{jm.userid},#{jm.gid}) " )
    public int AddGoodsa(@Param("jm") JM jm);

    @Select("select gid from JMFgoods where id=#{id}")
    public int selgid(@Param("id") Integer id);
}
